package com.meiqiongproperty.yiguanjia.fragment.home.health;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.meiqiongproperty.yiguanjia.R;
import com.meiqiongproperty.yiguanjia.databinding.PhysicianConsultDetailLayoutBinding;
import com.meiqiongproperty.yiguanjia.fragment.BaseFragment;
import com.meiqiongproperty.yiguanjia.http.api.ApiService;
import com.meiqiongproperty.yiguanjia.http.interfaces.IHttpCallback;
import com.meiqiongproperty.yiguanjia.http.sendJsonModel.SendPhysicianconsultDetail;
import com.meiqiongproperty.yiguanjia.httpbean.healthy.PhysicianConsultDetailBean;
import com.meiqiongproperty.yiguanjia.utils.Utils;

/**
 * author: Administrator
 * date: 2017/5/24.
 * package:com.meiqiongproperty.yiguanjia.fragment.home.health
 */

public class PhysicianConsultDetailFragment extends BaseFragment {
    PhysicianConsultDetailLayoutBinding binding;
    String askId;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.physician_consult_detail_layout, container, false);

        savedInstanceState = getArguments();
        if (savedInstanceState != null) {
            askId = savedInstanceState.getString("askId");
        }
        binding.navigation.setTitle("问题详情");
        binding.navigation.setLeftClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                sendKeyBackEvent();
            }
        });
        getConsultDetail();
        return binding.getRoot();
    }


    public void getConsultDetail(){
        SendPhysicianconsultDetail send=new SendPhysicianconsultDetail();
        send.setToken(Utils.getToken(getActivity()));
        send.setRoomID(Utils.getRoomID(getActivity()));
        send.setAskId(askId);
        Toast.makeText(getActivity(),askId,Toast.LENGTH_SHORT).show();
        ApiService.getPhysicianConsultDetail(getActivity(), new IHttpCallback<PhysicianConsultDetailBean>() {
            @Override
            public void onNext(PhysicianConsultDetailBean physicianConsultDetailBean) {
                binding.setConsultDetail(physicianConsultDetailBean.getAskdetail());
            }

            @Override
            public void onError(int code, String message) {

            }
        }, Utils.getRequestBody(send));
    }
}
